<?php
namespace Home\Controller;
use Think\Controller;
class CommonController extends Controller {
	/**
	 * [getTop 取热门的10条]
	 * @Author   Xuebingsi
	 * @DateTime 2017-04-03T15:21:37+0800
	 * @return   [type]                   [热门的10条问题]
	 */
	public function getTopView() {
		$sql = "select * from questions order by view_num desc limit 10";
		$hotView = M()->query($sql);
		$this->assign('hotView',$hotView);
	}
	
	/**
	 * [autoAdd 数据库表单自增]
	 * @DateTime 2017-04-03T15:20:09+0800
	 * @param    [type]                   $table [数据库表]
	 * @param    [type]                   $filed [字段]
	 * @param    [type]                   $num   [加减的数字]
	 * @param    [type]                   $id    [where的id]
	 */
	public function autoAdd ($table,$filed,$num,$id) {
		$sql = "update ".$table." set ".$filed."=".$filed.$num." where id='{$id}'";
		M()->execute($sql);
	}

	/**
	 * [getTopQuestion 取10条回答最多的问题]
	 * @Author   Xuebingsi
	 * @DateTime 2017-04-03T15:29:53+0800
	 * @return   [type]                   [10条回答最多的问题]
	 */
	public function getTopQuestion() {
		$sql = "select * from questions order by answer_num desc limit 10";
		$hotQuestion = M()->query($sql);
		$this->assign('hotQuestion',$hotQuestion);
	}






}
	